package thinkinjava4.ch18_io;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * 缓冲区输入文件
 */
public class BufferedInputFile {
    private static String fileBaseUrl = "src/thinkinjava4/ch18_io/";

    public static String read(String filename) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader(fileBaseUrl + filename));
        String s;
        StringBuilder sb = new StringBuilder();
        while ((s = in.readLine()) != null)
            sb.append(s + "\n");
        in.close();
        return sb.toString();
    }

    public static void main(String[] args) throws IOException {
        System.out.print(read("BufferedInputFile.java"));
    }
}
